package com.gitee.wsl.data.loader

import kotlinx.coroutines.flow.Flow
import kotlin.reflect.KClass

/**
 * Fetches and transfers data into a [ByteReadChannel] asynchronously.
 */
 interface DataFetcher<T : Any,out R> {

    /**
     * The KClass type for which this fetcher supports as a data input
     */
     val inputDataKClass: KClass<T>

    /**
     * Source from where data has been loaded.
     */
     val source: DataSourceType

    /**
     * Whether fetching from [T] is supported or not.
     */
     val T.isSupported: Boolean

    /**
     * fetches data [T] asynchronously as [ResourceResult] holding a [ByteReadChannel].
     * @param data type of data to fetch.
     * @param resourceConfig configuration used while fetching the resource.
     */
     fun fetch(data: T, resourceConfig: ResourceConfig): Flow<ResourceResult<R>>
}